<#include "admin/include/inside_header.ftl" >
<body>
  <@t.container title="添加角色" back="true" icon="puzzle-piece" > 
				<form class="form-horizontal" id="add_form" method="post" role="form">
					<#if bean??>
        				<input type="hidden" id="id" name="id" value="${bean.id}"/>	
					</#if>
					<@t.text title="角色名称" id="name" value="${bean.name!''}" />    
					<@t.submitBtn/>
                </form>
</@t.container>
<#include  "admin/include/footer.ftl">
 <script type="text/javascript">
     $(function(){
		//提交表单
       	  $('#add_form').validator({
        		theme: 'yellow_right_effect',  //设置theme
        		stopOnError: true, //
        		showOk:false,
        	    fields: {
        	        "name": {
        	            rule: "required;",
        	            ok: "",
        	            tip:"请填写角色名称",
        	            msg: {
        	            	required: "名称不可以为空!",
        	            }
        	        }
        	    }
        	});
		  $('#add_form').on('valid.form', function(e, form){
		  	   //成功之后刷新gd，关闭自己
			   var data=$(this).serialize();
			    var this_obj=$('#submit_btn');
				//提交表单
				this_obj.addClass('disabled');
				this_obj.html('提交中...');
               $ .axsf('admin/role/add',data,function(d){
			   		if(d){
                         if(d.code==200){
							window.location.href="admin/role/index";
                         }else{
						 	alert(d.message);
						 }
                	}
					 this_obj.removeClass("disabled");
             		 this_obj.html('保存');
			   });
        });
});
    </script>
	    </body>
    </html>